package com.gxlu.ms.web.config;

import javax.annotation.Resource;

import com.gxlu.ms.web.interceptor.BaseWebInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 *
 * @author andy.lhc
 * @date 2018/7/6
 */
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

    @Resource(name="baseWebInterceptor")
    private BaseWebInterceptor baseWebInterceptor ;

    /*@Bean(name="baseWebInterceptor1")
    public   BaseWebInterceptor getBaseWebInterceptor(){
        return  new BaseWebInterceptor();
    }*/

    /**
     * 注册 拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("---------"+baseWebInterceptor);
        registry.addInterceptor(baseWebInterceptor).addPathPatterns("/*");
        super.addInterceptors(registry);
    }
}

